package cn.wolfcode.service.impl;

import cn.wolfcode.domain.MessageBoardHjc;
import cn.wolfcode.mapper.MessageBoardHjcMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IMessageBoardHjcService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageBoardHjcServiceImpl implements IMessageBoardHjcService {

    @Autowired
    private MessageBoardHjcMapper messageBoardHjcMapper;


    @Override
    public void save(MessageBoardHjc messageBoardHjc) {
        messageBoardHjcMapper.insert(messageBoardHjc);
    }

    @Override
    public void delete(Long id) {
        messageBoardHjcMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(MessageBoardHjc messageBoardHjc) {
        messageBoardHjcMapper.updateByPrimaryKey(messageBoardHjc);
    }

    @Override
    public MessageBoardHjc get(Long id) {
        return messageBoardHjcMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<MessageBoardHjc> listAll() {
        return messageBoardHjcMapper.selectAll();
    }

    @Override
    public MessageBoardHjc selectById(Long id) {
        return messageBoardHjcMapper.selectById(id);
    }

    @Override
    public PageInfo<MessageBoardHjc> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<MessageBoardHjc> messageBoardHjcs = messageBoardHjcMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<MessageBoardHjc>(messageBoardHjcs);
    }
}
